Skip to content

[AWSX-2144] feat(go-forwarder): add basic api key and config logic#1084

Merged
ndakkoune merged 16 commits into
nabil.dakkoune/go-forwarderfrom
nabil.dakkoune/AWSX-2144-auth
Mar 26, 2026
Merged

[AWSX-2144] feat(go-forwarder): add basic api key and config logic#1084
ndakkoune merged 16 commits into
nabil.dakkoune/go-forwarderfrom
nabil.dakkoune/AWSX-2144-auth

Conversation

@ndakkoune
Copy link
Copy Markdown
Contributor

@ndakkoune ndakkoune commented Mar 20, 2026

What does this PR do?

Add the logging initialization, the configuration, the api key retrieval/verification strategies and their tests.

Motivation

Following the migration of the Log Forwarder to Go, the logging, the api key retrieval/verification and the loading/declaration of the configuration are required to test the most basic version of the new forwarder.

Testing Guidelines

Additional Notes

  • The proxy configuration should be configured through HTTP_PROXY and HTTPS_PROXY environment variables. We will probably deprecate the SSL skipping related flags for now.

Types of changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Check all that apply

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog
  • This PR passes the integration tests (ask a Datadog member to run the tests)
  • This PR passes the unit tests
  • This PR passes the installation tests (ask a Datadog member to run the tests)

@github-actions github-actions Bot added the aws label Mar 20, 2026
@ndakkoune ndakkoune marked this pull request as ready for review March 20, 2026 15:12
@ndakkoune ndakkoune requested a review from a team as a code owner March 20, 2026 15:12
Comment on lines +56 to +60

if err := cfg.resolveAPIKey(ctx); err != nil {
return nil, fmt.Errorf("resolving API key: %w", err)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be one function

Comment thread aws/logs_monitoring_go/internal/config/apikey.go Outdated
Comment thread aws/logs_monitoring_go/internal/config/apikey.go Outdated
Comment thread aws/logs_monitoring_go/cmd/forwarder/main.go Outdated
Comment thread aws/logs_monitoring_go/cmd/forwarder/main.go Outdated
Comment thread aws/logs_monitoring_go/cmd/forwarder/main.go Outdated
Comment thread aws/logs_monitoring_go/internal/config/apikey.go Outdated
Comment thread aws/logs_monitoring_go/internal/config/apikey.go
Comment thread aws/logs_monitoring_go/internal/config/apikey.go Outdated
Comment thread aws/logs_monitoring_go/internal/config/apikey_test.go Outdated
Comment thread aws/logs_monitoring_go/internal/config/config.go Outdated
Comment thread aws/logs_monitoring_go/cmd/forwarder/main.go
Comment thread aws/logs_monitoring_go/internal/config/apikey.go Outdated
Comment thread aws/logs_monitoring_go/internal/config/apikey.go Outdated
Comment thread aws/logs_monitoring_go/internal/config/apikey.go Outdated
Comment thread aws/logs_monitoring_go/internal/config/config.go Outdated
Comment thread aws/logs_monitoring_go/internal/config/secretsmanager_test.go Outdated
Comment thread aws/logs_monitoring_go/Makefile Outdated
# SAM
.PHONY: build-ForwarderFunction sam-build sam-invoke sam-deploy

build-ForwarderFunction:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 suggestion: ‏ Are we allowed to change case here? Can we stick to kebab-case? It's a mix of PascalCase and kebab-case that is disturbing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command is (and should only be) used by the sam build command, which use whatever is written after build- to create a function named ForwarderFunction in the cloudformation template (local).

Comment thread aws/logs_monitoring_go/Makefile Outdated
Comment thread aws/logs_monitoring_go/cmd/forwarder/main.go Outdated
Comment thread aws/logs_monitoring_go/internal/config/apikey.go Outdated
Comment thread aws/logs_monitoring_go/internal/config/apikey.go Outdated
Comment thread aws/logs_monitoring_go/internal/config/apikey.go Outdated
Comment thread aws/logs_monitoring_go/internal/config/apikey.go Outdated
Copy link
Copy Markdown
Contributor

@ViBiOh ViBiOh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocker, good if you can do it before merging

Comment thread aws/logs_monitoring_go/internal/config/apikey.go
Comment thread aws/logs_monitoring_go/internal/config/apikey.go Outdated
Comment thread aws/logs_monitoring_go/internal/config/config_test.go Outdated
Comment on lines +15 to +16
func TestLoadConfig(t *testing.T) {
tests := map[string]struct {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func TestLoadConfig(t *testing.T) {
tests := map[string]struct {
func TestLoadConfig(t *testing.T) {
t.Parallel()
tests := map[string]struct {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t.Parallel() cannot be used with t.Setenv(k,v) since the latter affects the whole process.

Comment thread aws/logs_monitoring_go/internal/config/config_test.go
Comment thread aws/logs_monitoring_go/internal/config/environment.go
if !ok {
return fallback
}
return strings.EqualFold(v, "true")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 thought: ‏ I'm wondering if we should support the "1" value etc?

You might prefere using ParseBool that will handle everything for you.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We lose nothing by doing so. Let's use it.

Comment thread aws/logs_monitoring_go/internal/config/environment_test.go
Comment thread aws/logs_monitoring_go/internal/config/secretsmanager.go

package config

//go:generate go tool mockgen -source=secretsmanager.go -package=config -destination=secretsmanager_mockgen.go
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll move the mock to a dedicated package later I think, to not have be part of the production bundle. Ok for now

ndakkoune and others added 6 commits March 26, 2026 09:16
Co-authored-by: Vincent Boutour <vincent.boutour@datadoghq.com>
Co-authored-by: Vincent Boutour <vincent.boutour@datadoghq.com>
Co-authored-by: Vincent Boutour <vincent.boutour@datadoghq.com>
Co-authored-by: Vincent Boutour <vincent.boutour@datadoghq.com>
@ndakkoune ndakkoune merged commit e8e336b into nabil.dakkoune/go-forwarder Mar 26, 2026
10 checks passed
@ndakkoune ndakkoune deleted the nabil.dakkoune/AWSX-2144-auth branch March 26, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants